<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui">

    <h:form id="ClienteListForm">

        <p:panel header="#{bundle.ListClienteTitle}">
            <p:dataTable id="datalist" value="#{clienteController.items}" var="item"
                         selectionMode="single" selection="#{clienteController.selected}"
                         rowKey="#{item.id}"
                         paginator="true"
                         rows="5"
                         rowsPerPageTemplate="5,10,15"
                         >

                <p:ajax event="rowSelect"   update="createButton, :tabViewCliente:display, :tabViewCliente:display:PessoaEditForm"/>
                <p:ajax event="rowUnselect" update="createButton, :tabViewCliente:display, :tabViewCliente:display:PessoaEditForm"/>
                <p:column sortBy="#{item.pessoa}" filterBy="#{item.pessoa}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListClienteTitle_tipo}"/>
                    </f:facet>
                    <h:outputText value="#{item.pessoa.tipo}"/>
                </p:column>
                <p:column sortBy="#{item.pessoa}" filterBy="#{item.pessoa}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListClienteTitle_pessoa}"/>
                    </f:facet>
                    <h:outputText value="#{item.pessoa}"/>
                </p:column>
                <p:column sortBy="#{item.desde}" filterBy="#{item.desde}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListClienteTitle_desde}"/>
                    </f:facet>
                    <h:outputText value="#{item.desde}">
                        <f:convertDateTime pattern="dd/MM/yy" />
                    </h:outputText>
                </p:column>

                <p:column sortBy="#{item.conheceuPor}" filterBy="#{item.conheceuPor}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListClienteTitle_conheceuPor}"/>
                    </f:facet>
                    <h:outputText value="#{item.conheceuPor}"/>
                </p:column>
                <f:facet name="footer">
                    <div class="footer-section">
                        <p:commandButton id="createButton" icon="ui-icon-plus"   value="#{bundle.Create}" actionListener="#{clienteController.prepareCreate}" update=":ClienteCreateForm" oncomplete="ClienteCreateDialog.show()"/>
                    </div>
                </f:facet>
            </p:dataTable>
        </p:panel>
        <ui:include src="/WEB-INF/include/confirmation.xhtml"/>
    </h:form>
    <p:tabView id="tabViewCliente">
        <p:tab title="#{bundle.ListClientTabPrincipal}">
            <ui:include src="/WEB-INF/include/entity/cliente/EditPessoa.xhtml"/>
        </p:tab>
        <p:tab title="#{bundle.ListClientTabSolicitacoes}"></p:tab>
        <p:tab title="#{bundle.ListClientTabFinanceiro}"></p:tab>
        <p:tab title="#{bundle.ListClientTabPacotes}"></p:tab>            
    </p:tabView>    
</ui:composition>